/**
 * Copyright 2010 Adam Ruggles.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package saig.engine.editors;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import javax.swing.JTabbedPane;

import saig.engine.models.Model;
import saig.engine.models.Tile;


/**
 * Selector Pane, a pane to display selectable items for a level in the map editor.
 * @author Adam
 * @version $Id$
 * 
 * Created on Jun 20, 2010 at 3:40:08 PM 
 */
public class SelectorPane extends JPanel {
	/**
	 * The model pane is active.
	 */
	public static final int MODEL_PANE = 1;
	/**
	 * No pane is active.
	 */
	public static final int NO_PANE = -1;
	/**
	 * Serial Version UID.
	 */
	private static final long serialVersionUID = -6288401633676095685L;
	/**
	 * The tile pane is active.
	 */
	public static final int TILE_PANE = 0;
	/**
	 * The model pane.
	 */
	private ModelPane modelPane = null;
	/**
	 * The tabbed pane.
	 */
	private JTabbedPane tabbedPane = null;
	/**
	 * The tile pane.
	 */
	private TilePane tilePane = null;
	/**
	 * Constructs the tile pane with a map of tiles.
	 * @param tileMap The map of tiles.
	 */
	public SelectorPane() {
		setLayout(new BorderLayout());
		add(getTabbedPane());
	}
	/**
	 * The value for the active Pane (TILE_PANE, MODEL_PANE).
	 * @return The value for the active pane.
	 */
	public int getActivePane() {
		return tabbedPane.getSelectedIndex();
	}
	/**
	 * Returns the selected model.
	 * @return The selected model.
	 */
	public Model getSelectedModel() {
		return modelPane.getTarget();
	}
	/**
	 * Returns the selected tile.
	 * @return the selected tile.
	 */
	public Tile getSelectedTile() {
		return tilePane.getTarget();
	}
	/**
	 * Returns a tabbed pane.
	 * @return The tabbed pane.
	 */
	private JTabbedPane getTabbedPane() {
		if (tabbedPane == null) {
			tabbedPane = new JTabbedPane();
			tilePane = new TilePane();
			modelPane = new ModelPane();
			tabbedPane.addTab("Tiles", tilePane);
			tabbedPane.addTab("Models", modelPane);
		}
		return tabbedPane;
	}
}
